/* Base styles */
body {
    margin: 0;
    padding: 5px;
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
}
.chat-head{
    display: grid;
    grid-template-columns: auto 1fr auto; 
    background-color: #ccc;    
    padding:8px 20px;
}
#id{
    font-weight: bold;
}
.chat-container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 50px);
    min-height: 85vh; 
    border:1px solid black;
    overflow: hidden;
}

#chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.input-container{
    padding: 10px;
    display: flex;
    gap: 10px;
    border-top: 1px solid #ddd;
    align-items: center;
}
.media-controls {
    padding: 10px;
    padding-top: 0px;
    display: flex;
    gap: 10px;
    align-items: center;
}

#message-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

#submit-message,
#submit-image,
#submit-file,
.record-button {
    padding: 10px 20px;
    background-color:white;
    color: black;
    border:1px solid black;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#submit-message:hover,
#submit-image:hover,
#submit-file:hover,
.record-button:hover {
    background-color:#ddd;
}

.record-button.recording {
    background-color:orange;
}

.record-button.recording:hover {
    background-color:gold;
}

#file-input {
    display: none;
}

/* Message styling */
.message {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 8px 12px;
    word-wrap: break-word;
    width: fit-content;
    max-width: 70%;
    box-sizing: border-box;
}

.sent {
    align-self: flex-end;
    color:black;
    flex-direction: row-reverse;
}

.received {
    align-self: flex-start;
    color: black;
    flex-direction: row;
}

.message-sender {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
    position: absolute;
    top: 10px;
    border:1px solid black;
    color:black;
}

.sent .message-sender {
    right: -10px;
}
.received .message-sender {
    left: -10px;
}
.message-text-body {
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    padding: 8px 12px;
    max-width: 100%;
    border:1px solid black;
}
.sent .message-text-body{
    margin-right: 30px;
    background-color: #f0f0f0;
}
.received .message-text-body{
    margin-left:30px;
    background-color: #ccc;
}


.message-text {
    margin-bottom: 4px;
    word-wrap: break-word;
    max-width: 100%;
    font-size: 14px;
}

.timestamp {
    font-size: 10px;
    opacity: 0.7;
    text-align: right;
}

.sent .timestamp {
    text-align: right;
}

.received .timestamp {
    text-align: left;
}

.message-image {
    max-width: 100%;
    border-radius: 4px;
}

.system-message {
    text-align: center;
    color: #666;
    font-size: 12px;
    padding: 5px;
}

.error {
    color: #dc3545;
}

.connection-status {
    margin-top: 5px;
    width: 12px; 
    height: 12px; 
    border-radius: 50%;
    border: 1px solid #ccc;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    background-color: grey;
    transition: background-color 0.3s ease; 
}

.connection-status.connected {
    background: #28a745;
}

.connection-status.disconnected {
    background: #ffc107;
}

.connection-status.error {
    background: #dc3545;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.image-container {
    margin: 10px 0;
}

.chat-image.thumbnail {
    max-width: 200px;
    max-height: 200px;
    cursor: pointer;
    border-radius: 4px;
}

.full-image-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    cursor: pointer;
}

.full-image {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
}

audio {
    max-width: 100%;
    margin-top: 5px;
}
.upload-status {
    font-size: 14px;
    display: none;
    flex-wrap: wrap;
    justify-content: space-between;
    background-color: #8BC34A;
    color: whitesmoke;
    overflow: hidden;
    gap: 10px; 
}

#upload-file-input {
    flex: 0;
    width:120px; 
}
#uploadBtnContainer{
    flex: 0;
    white-space: nowrap;
}
#statusText {
    flex: 1; 
    min-width: 50px;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.video-container {
    max-width: 100%;
    display: inline-block;
    position: relative;
}

.chat-video {
    width: 100%; 
    height: auto; 
    max-height: 300px; 
    object-fit: contain;
}

.full-video-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.full-video {
    max-width: 80%;
    max-height: 80%;
}
.progress-container {
    width: 100%;
    background-color: #ddd;
    height: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  }
.progress-bar {
    height: 100%;
    width:0%;
    background-color: #4caf50;
    text-align: center;
    line-height: 8px;
    transition: width 0.5s ease-in-out;
  }
  .toast {
    position: fixed;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #f44336;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 15px;
    visibility: hidden; 
    opacity: 0; 
    transition: opacity 0.5s, visibility 0.5s; 
    z-index: 1000;
  }
  .toast.show {
    visibility: visible;
    opacity: 1;
  }
  .toast.error {
    background-color: #f44336; 
  }
  .toast.success {
    background-color: #4CAF50; 
  }
  .qrcode-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.qrcode-small {
    width: 32px;
    height: 32px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.qrcode-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.qrcode-large {
    width: 256px;
    height: 256px;
    border: 5px solid white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.qrcode-overlay:active {
    display: none;
}